package Exercise;

/**
 * @author 王艺锡
 * @version 1.0
 */
public class Exercise04 {
    public static void main(String[] args) {
    String str = "1354sadad a465A SDASD@q q.......";
    search(str);
    }

    public static void search(String str) {
        if (str == null) {
            System.out.println("字符串不能为空!");
            return;
        }
        int numCount = 0;
        int lowerCount = 0;
        int upperCount = 0;
        int otherCount = 0;
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) >= '0' && str.charAt(i) <= '9') {
                numCount++;
            }
            else if (str.charAt(i) >= 'a' && str.charAt(i) <= 'z') {
                lowerCount++;
            }
            else if (str.charAt(i) >= 'A' && str.charAt(i) <= 'Z') {
                upperCount++;
            }else {
                otherCount++;
            }
        }
        System.out.println("数字:" + numCount + "小写字母:" + lowerCount +
                "大写字母:" + upperCount + "其他字符:" + otherCount);

    }
}
